package com.example.administrator.chinafood;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.GridView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PersonRbBad extends AppCompatActivity {

    private GridView gridView;
    private List<Map<String, Object>> data_list;
    String []name = {"葱花糖水","秘制鲱鱼","苦味豆腐","鸡鱼炸丸","红烧香蕉","酸辣烤肉"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.person_rb_bad);
        gridView = (GridView)findViewById(R.id.person_rb_bad_gridView);

        getData();
        String []from = {"name"};
        int []to = {R.id.person_rb_bad_gridView_txt};
        SimpleAdapter simpleAdapter = new SimpleAdapter(PersonRbBad.this, data_list, R.layout.adapter_gridview_person_rb_bad, from, to);
        gridView.setAdapter(simpleAdapter);
    }

    public List<Map<String, Object>> getData(){
        data_list = new ArrayList<Map<String, Object>>();
        for(int i=0;i<name.length;i++){
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("name", name[i]);
            data_list.add(map);
        }
        return data_list;
    }
}
